package com.sunxd.vue.application.controller;

import com.sunxd.vue.bean.Response;
import com.sunxd.vue.bean.request.LoginReq;
import com.sunxd.vue.bean.request.LoginCheckRequest;
import com.sunxd.vue.domain.service.AuthService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

import static com.sunxd.vue.infrastructure.utils.ResponseHelper.or500;

/**
 * @author sun.xd
 * @description: description
 * @date 2024/4/2 15:39
 */
@RestController
@RequestMapping(value = "auth")
@RequiredArgsConstructor
public class AuthController {

    private final AuthService authService;

    @RequestMapping(value = "login")
    public Response<String> login(@RequestBody LoginReq req){
        return or500(()->authService.login(req));
    }

    @RequestMapping(value = "login2")
    public Response<String> login2(@RequestBody LoginCheckRequest req){
        return or500(()->authService.login2(req));
    }

    @RequestMapping(value = "auth")
    public Response<String> auth(HttpServletRequest servletRequest){
        return or500(()->authService.auth(servletRequest));
    }

    @RequestMapping(value = "checkTest")
    public Response<String> checkTest(){
        return Response.createSuccess("abc");
    }

}
